﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Diagnostics;
using System.Windows.Forms;
using Contract;
using System.IO;

namespace client
{
    public partial class Register : Form
    {
        int PCN;
        public Register()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            NetTcpBinding binding = new NetTcpBinding();
            binding.TransferMode = TransferMode.Streamed;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.MaxReceivedMessageSize = 9223372036854775807;

            EndpointAddress address = new EndpointAddress("net.tcp://82.171.131.226:5000/DataUploader");

            ChannelFactory<IDataUploader> channel = new ChannelFactory<IDataUploader>(binding, address);
            IDataUploader Proxy = channel.CreateChannel();
            string Email = textBox1.Text.Trim();
            string Password = textBox2.Text.Trim();
            string Pawconfirm = textBox3.Text.Trim();
            string Gender = textBox4.Text.Trim();
            string Fname = textBox5.Text.Trim();
            string Lname = textBox6.Text.Trim();
           
            try
            {
               
                if (Email==""||Password==""||Gender==""||Fname==""||Lname==""||Pawconfirm!= Password)
                {
                    MessageBox.Show("You must fill all blanks!! The Password and the password confirm do not match!");
                }
                else
                    PCN=Proxy.Register(Email, Password, Gender, Fname, Lname);
                
                   if(PCN.ToString()!="" ) 
                   {     
                       Form1 fr = new Form1(PCN.ToString());
                       fr.Show();
                   }
                
                    else
                        MessageBox.Show("fail");
                }



            

            catch
            {
                MessageBox.Show("fail");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {

            NetTcpBinding binding = new NetTcpBinding();
            binding.TransferMode = TransferMode.Streamed;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.MaxReceivedMessageSize = 9223372036854775807;

            EndpointAddress address = new EndpointAddress("net.tcp://82.171.131.226:5000/DataUploader");

            ChannelFactory<IDataUploader> channel = new ChannelFactory<IDataUploader>(binding, address);
            IDataUploader Proxy = channel.CreateChannel();
            MyFile[] f= Proxy.test1();
            MessageBox.Show(f[0].PCN, f[0].Name);
        }
        
    }
}
